/* About this program :
 * Problem number : UVa's ACM 00476
 * Author : Ives Liao
 * Submit time's : 5 times
 * Result : Accepted. (2010/Oct./03 17:10 PM)
 *
 */
typedef struct COORDINATE_DEF {
    float x, y;
} COORD;

typedef struct RECTANGLE_DEF {
    COORD up_left, low_right;
} RECTANGLE;

#define MAX_FIGURE_NUM 10

#ifdef ONLINE_JUDGE
    #include<stdio.h>
    #include<stdlib.h>
    #define TRUE 1
    #define FALSE 0
    #define INPUT stdin
    int main(){
#else
    #include"header.h"
    #define INPUT fptIn
    int acm_00476() {
        printf("--ACM 476 begin here--\n");
        FILE *fptIn = fopen("Resource/acm_00476.txt", "r");
        if ( fptIn == NULL )//Distinguish the INPUT file is load success.
        {
            printf("File acm_00476.txt load fail.\n");
            printf("Program will exit.\n");
            return EXIT_FAILURE;
        }
#endif

    int fig_num, rect_ctr, point_ctr, in_rect;
    float x, y;
    char ch;
    RECTANGLE rect_range[MAX_FIGURE_NUM];

    if (INPUT == NULL)//Distinguish the input file is load success.
    {
        printf("File input.txt load fail.\n");
        printf("Program will exit.\n");
        exit(1);
    }
    if (stdout == NULL)//Distinguish the output file is load success.
    {
        printf("File output.txt creat fail.\n");
        printf("Program will exit.\n");
        exit(1);
    }
    ch = getc(INPUT); //Get the first flag of data.
    fig_num = 0; //Default the rectangle number conter.
    while (ch != '*') {
        if (ch == 'r')//If the flag is  rectangle's flag
        {
            fscanf(INPUT, " %f %f %f %f\n", &rect_range[fig_num].up_left.x, &rect_range[fig_num].up_left.y, &rect_range[fig_num].low_right.x, &rect_range[fig_num].low_right.y);
            fig_num = fig_num + 1; //Add rectangle's number conter.
        }
        ch = getc(INPUT); //Get the next data's flag.
    }
    fscanf(INPUT, "%f %f\n", &x, &y); //Scan the first point.
    point_ctr = 1; //Default the point_conter.
    while ((int) (x * 10) != 99999 && (int) (y * 10) != 99999) {
        rect_ctr = 0; //Default rect_conter to 0.
        in_rect = FALSE; //Default in_rect to fail.
        while (rect_ctr <= fig_num) {//Run the loop to distinguish all rectangle.
            if (x < rect_range[rect_ctr].low_right.x && y > rect_range[rect_ctr].low_right.y && x > rect_range[rect_ctr].up_left.x && y < rect_range[rect_ctr].up_left.y) {//Distinguish the point is in the rectangle
                fprintf(stdout, "Point %d is contained in figure %d\n", point_ctr, rect_ctr + 1);
                in_rect = TRUE; //Set the flag to TRUE.
            }
            rect_ctr = rect_ctr + 1; //To next rectangle's data.
        }

        if (in_rect == FALSE)//If not in any rectangle do this.
        {
            fprintf(stdout, "Point %d is not contained in any figure\n", point_ctr);
        }
        fscanf(INPUT, "%f %f\n", &x, &y); //Scan next point.
        point_ctr = point_ctr + 1;
    }
    #ifndef ONLINE_JUDGE
        fclose(INPUT); //Close the input file.
        printf("--ACM 476 end here--\n");
    #endif
    return 0;
}
